<template>
  <a-modal v-model="visible" :width="1080" title="选择开机广告" @ok="batchSelectItem">
    <!-- 查询区域 -->
    <!--<div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>-->
    <!-- 查询区域-END -->

    <!-- table区域-begin -->
    <div>

      <a-table ref="table" size="middle" bordered rowKey="id" :columns="columns" :dataSource="dataSource" :pagination="ipagination" :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange,type:selectionType}" class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="55px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;" />
        </template>
<template slot="fileSlot" slot-scope="text">
  <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
  <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
    下载
  </a-button>
</template>

<span slot="action" slot-scope="text, record">
<a @click="selectItem(record)">选择</a>
        </span>

        </a-table>
        </div>

        </a-modal>
        </template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/MyJeecgListMixin'


export default {
  name: 'CmsIndexAdList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
  },
  data () {
    return {
      pageCheckedKeys: [],
      noPageCheckedKeys: [],
      pageCheckedRows: [],
      noPageCheckedRows: [],
      visible: false,
      description: '开机广告管理页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: "center",
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '是否启用1（true）启用，0(false)不启用',
          align: "center",
          dataIndex: 'sw',
          customRender: (text) => (text ? filterMultiDictText(this.dictOptions['sw'], text) : ''),
        },
        {
          title: '图片',
          align: "center",
          dataIndex: 'imgUrl',
          scopedSlots: { customRender: 'imgSlot' }
        },
        {
          title: '显示秒数',
          align: "center",
          dataIndex: 'seconds'
        },
        {
          title: '点击效果类型（全局统一）',
          align: "center",
          dataIndex: 'type_dictText'
        },
        {
          title: '点击效果对应参数',
          align: "center",
          dataIndex: 'param'
        },
        {
          title: '修改模板用户主键',
          align: "center",
          dataIndex: 'updateBy'
        },
        {
          title: '创建模板用户主键',
          align: "center",
          dataIndex: 'createBy'
        },
        {
          title: '创建时间',
          align: "center",
          dataIndex: 'createTime'
        },
        {
          title: '更新时间',
          align: "center",
          dataIndex: 'updateTime'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: "/modules.common/cmsIndexAd/list",
        delete: "/modules.common/cmsIndexAd/delete",
        deleteBatch: "/modules.common/cmsIndexAd/deleteBatch",
        exportXlsUrl: "/modules.common/cmsIndexAd/exportXls",
        importExcelUrl: "modules.common/cmsIndexAd/importExcel",

      },
      dictOptions: {},
    }
  },
  created () {
    this.$set(this.dictOptions, 'sw', [{ text: '是', value: 'Y' }, { text: '否', value: 'N' }])
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    open () {
      this.loadData()
    },
    setSelected () {
      this.pageCheckedKeys = []
      this.noPageCheckedKeys = []
      this.pageCheckedRows = []
      this.noPageCheckedRows = []
      for (let i = 0; i < this.checkedKeys.length; i++) {
        let isSelect = false
        for (let j = 0; j < this.dataSource.length; j++) {
          if (this.dataSource[j].id == this.checkedKeys[i]) {
            isSelect = true
          }
        }
        if (isSelect) {
          this.pageCheckedKeys.push(this.checkedKeys[i])
          this.pageCheckedRows.push(this.checkedRows[i])
        } else {
          this.noPageCheckedKeys.push(this.checkedKeys[i])
          this.noPageCheckedRows.push(this.checkedRows[i])
        }
      }
      this.selectedRowKeys = this.pageCheckedKeys
    },
    initDictConfig () {
    }
  }
}
        </script>
<style scoped>
@import '~@assets/less/common.less';
</style>
